package com.zipking.cloud.springbootmybatis.util;

import lombok.extern.slf4j.Slf4j;

import java.util.Date;
import java.util.stream.Collectors;
@Slf4j
public class ESTest {
    public static void main(String[] args) {
        Date fiveMinutesAgoDate = new Date(new Date().getTime() - 5 * 60 * 1000L);
      //  List<Article> articleList = articleMapper.listArticleWithData(fiveMinutesAgoDate);
        //if (CollectionUtils.isNotEmpty(articleList)) {
            //List<ESArticle> esArticleList = articleList.stream().map(ESArticle::dbToEs).collect(Collectors.toList());
            final int pageSize = 20;
            int total = 50000;
            log.info("------------IncSyncArticleToES start!-----------, total {}", total);
            for (int i = 0; i < total; i += pageSize) {
                int end = Math.min(i + pageSize, total);
                log.info("sync from {} to {}", i, end);
              //  articleRepository.saveAll(esArticleList.subList(i, end));
            }
            log.info("------------IncSyncArticleToES end!------------, total {}", total);
       // }

    }
}
